home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: redoGetUnique.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:57 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "latch.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "log.h"
- #include "volume.h"
- #include "logrecs.h"
- #include "trans.h"
- #include "bitmap.h"
- #include "openlog.h"
- #include "io_extfuncs.h"
- #include "bf_extfuncs.h"
- #include "bm_extfuncs.h"
- #include "trans_extfuncs.h"
- #include "redo_extfuncs.h"
- #include "logaction.h"
- #include "util_funcs.h"
- #include "thread_globals.h"
- #include "log_globals.h"
- #include "log_extfuncs.h"
-
-
- void
- redoGetUnique (
-
- LOGRECORDHDR *record
- )
- {
-
- register VOLREC *volRec;
- register PID *pid;
- register GROUPLINK *groupLink;
- register UNIQUE *mapPtr;
- UNIQUE *unique;
- FOUR *word;
- PID bitmapPid;
- DIRTYPAGEINFO *dirtyInfo;
- BITMAPPAGE *bitmapPage;
-
-
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_1, ("lsn:%d", record->recordLSN.offset));
-
- /*
- * get a pointer to the name in the record
- */
- pid = &(record->actionPid);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
- /*
- * get a pointer to the name in the record
- */
- word = (FOUR *) GET_LOG_IMAGE(record, 0);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("word:%d", *word));
-
- /*
- * get a pointer to the name in the record
- */
- unique = (UNIQUE *) GET_LOG_IMAGE(record, 1);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("unique:%d", *unique));
-
- /*
- * check to see if the page is in the dirty page list
- */
- if ((dirtyInfo = searchDirtyPageTable(pid)) == NULL) {
-
- /*
- * don't need to redo
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty page not present"));
- return;
- }
-
- /*
- * check to see if the lrc on the page is greater than
- * the lrc in the log record.
- * Also check the lsn for the case of pages which never made it
- * back from the client.
- */
- if (CHECK_PAGE_LRC_LESS_DIRTYINFO(record->actionLRC, record->recordLSN, dirtyInfo)) {
-
- /*
- * don't need to redo
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty info page lrc later"));
- return;
- }
-
- if ((volRec = io_FindVolRec(pid->volid)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /*
- * initialize the pid with the volume
- */
- bitmapPid.volid = volRec->header->volid;
- bitmapPid.page = pid->page;
-
- /*
- * read in the page
- */
- if ((groupLink = bf_ReadPage(volRec->bufGroup, &bitmapPid,
- BITMAP_PAGE2SIZE, BF_SEM)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * get a pointer to the bitmap page
- */
- bitmapPage = (BITMAPPAGE *) groupLink->bufFrame;
-
- /*
- * check to see if the lrc on the page is greater than
- * the lrc in the log record
- */
- if (compareLRC( &(record->actionLRC), &(bitmapPage->lrc)) <= 0) {
-
- /*
- * don't need to redo
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("actual page lrc later"));
-
- /*
- * mark the page lrc
- */
- dirtyInfo->lrc = bitmapPage->lrc;
-
- /*
- * release the page, clean
- */
- signalSemaphore( &(groupLink->pageHash->semaphore) );
- bf_UnfixPage(groupLink, BF_DEFAULT, FALSE);
- return;
- }
-
- /*
- * get the pointer to the word map
- */
- mapPtr = (UNIQUE *) groupLink->bufFrame;
-
- /*
- * get the current unique value
- */
- mapPtr[*word] = *unique;
- TRPRINT(TR_IO, TR_LEVEL_2, ("unique:%x", *unique));
-
- /*
- * mark the lrc
- * Set up the firstLSN/LRC for the page
- */
- bitmapPage->lrc = record->actionLRC;
- DEPEND_LOG(groupLink->pageHash, 0, &(record->recordLSN), &(record->actionLRC));
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("marking new page lrc:%d", bitmapPage->lrc.count));
-
- /*
- * signal the semaphore
- */
- signalSemaphore( &(groupLink->pageHash->semaphore) );
-
- /*
- * unfix the page
- */
- bf_UnfixPage(groupLink, BF_DEFAULT, TRUE);
- }
-